#ifndef SIGMOID_H
#define SIGMOID_H

#include <cmath>
#include "activation_function.h"

class Sigmoid : public ActivationFunction {
public:
    std::vector<std::vector<float>> apply(const std::vector<std::vector<float>>& Z) override {
        std::vector<std::vector<float>> A(Z.size(), std::vector<float>(Z[0].size()));
        for (size_t i = 0; i < Z.size(); ++i) {
            for (size_t j = 0; j < Z[i].size(); ++j) {
                A[i][j] = 1.0 / (1.0 + std::exp(-Z[i][j]));
            }
        }
        return A;
    }

    std::vector<std::vector<float>> applyDerivative(const std::vector<std::vector<float>>& Z) override {
        std::vector<std::vector<float>> A_prime(Z.size(), std::vector<float>(Z[0].size()));
        for (size_t i = 0; i < Z.size(); ++i) {
            for (size_t j = 0; j < Z[i].size(); ++j) {
                float sigmoid = 1.0 / (1.0 + std::exp(-Z[i][j]));
                A_prime[i][j] = sigmoid * (1 - sigmoid);
            }
        }
        return A_prime;
    }

    std::string getType(){
        return "Sigmoid";
    }
};

#endif // SIGMOID_H
